package com.block.common.encrypt.service.type;

import cn.hutool.crypto.SecureUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.block.common.encrypt.service.IEncryptTypeServcie;
import com.block.common.model.dto.EncryptKeyDTO;
import org.springframework.stereotype.Service;

import java.nio.charset.StandardCharsets;

@Service
public class AesEncrpytService implements IEncryptTypeServcie {

    @Override
    public JSONObject decryptTranData(EncryptKeyDTO keyInfoDTO, JSONObject paramObject) {
        String content = paramObject.getString("tranData");
        String deContent = SecureUtil.aes(keyInfoDTO.getAppSecret().getBytes(StandardCharsets.UTF_8)).decryptStr(content);
        return JSON.parseObject(deContent);
    }
}
